/**
 * Project: d20Engine
 * Created: Aug 20, 2006 by bebopJMM
 */
package org.rollinitiative.d20.combat;

import org.rollinitiative.d20.entity.AbilityListenerValue;

/**
 * This class represents an initiative value for a single combatant over the course of an encounter.
 * 
 * TODO Add support for impact of 1/20 base roll.
 * TODO Add support for adjustment during encounter (delay, ready, etc.)
 * 
 * @author bebopJMM
 * 
 */
public class Initiative
{
    /**
     * Initiative value, initial value is derived from baseRoll + modifier
     */
    private int value_ = 0;

    /**
     * Base number of initiative (1d20)
     */
    private int baseRoll_ = 0;

    /**
     * Modifier to be applied to baseRoll
     */
    private AbilityListenerValue modifier_;

    /**
     * Tie-breaking roll when baseRoll and modifier match another (1d100)
     */
    private int tieRoll_ = 0;


    public Initiative(AbilityListenerValue actorModifier)
    {
        this.modifier_ = actorModifier;      
    }
    
    
    /**
     * @return the baseRoll input into the initiative value.
     */
    public int getBaseRoll()
    {
        return this.baseRoll_;
    }


    /**
     * Sets the baseRoll value (typically 1..20)
     * 
     * @param baseRoll the baseRoll value.
     */
    public void setBaseRoll(int baseRoll)
    {
        this.baseRoll_ = baseRoll;
        this.value_ = baseRoll + modifier_.getCurrent();
        this.tieRoll_ = 0; // reset
    }


    /**
     * @return the current initiative value.
     */
    public int getValue()
    {
        return value_;
    }


    /**
     * @return the modification to the baseRoll due to actor's abilities and talents.
     */
    public int getModifier()
    {
        return modifier_.getCurrent();
    }


    /**
     * @return the tieRoll
     */
    public int getTieRoll()
    {
        return tieRoll_;
    }


    /**
     * @param tieRoll new tieRoll value.
     */
    public void setTieRoll(int tieRoll)
    {
        this.tieRoll_ = tieRoll;
    }

    
}
